package simulation;

import java.util.HashSet;
import java.util.Set;

public class GoatLatin824 {
    public String toGoatLatin(String sentence) {
        String[] strings = sentence.split(" ");
        Set<Character> set = new HashSet<>();
        set.add('a');
        set.add('e');
        set.add('i');
        set.add('o');
        set.add('u');
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < strings.length; i++) {
            String s = strings[i];
            if (!set.contains(Character.toLowerCase(s.charAt(0)))) {
                sb.append(s.substring(1));
                sb.append(s, 0, 1);
            }else {
                sb.append(s);
            }
            sb.append("ma");
            for (int j = 0; j < i + 1; j++) {
                sb.append('a');
            }
            sb.append(' ');
        }
        return sb.substring(0,sb.length()-1);
    }
}
